package cn.czxy.web.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.LinkedHashMap;

/**
 * @author 杨先生
 * @version 1.0
 * @date 2019/4/12
 */
public class ServletContextListener11 implements ServletContextListener {

    /**
     * 监听context创建 添加一些数据
     * @param servletContextEvent
     */
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        //在服务器创建的时候 生成一个文件夹的类型
        LinkedHashMap<String,String> hashMap = new LinkedHashMap<>();
        hashMap.put("/","全部文件");
        hashMap.put("/imges","图片");
        hashMap.put("/texts","文本");
        hashMap.put("/music","音乐");
        hashMap.put("/videos","视频");
        hashMap.put("/other","其他");
        servletContextEvent.getServletContext().setAttribute("FilePath",hashMap);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
